<form id="pagerForm" method="post" action="<?php echo SITE_URL . 'index.php?c=user&a=setrole&user_id='.$user_id;?>">
    <input type="hidden" name="pageNum" value="1" />
    <input type="hidden" name="numPerPage" value="<?php echo $list['pager']->per_page;?>" />
    <input type="hidden" name="role_name" value="<?php echo $_input->post('role_name');?>" />
</form>

<div class="pageHeader">
    <form rel="pagerForm" method="post" action="<?php echo SITE_URL . 'index.php?c=user&a=setrole&user_id='.$user_id;?>" onsubmit="return dwzSearch(this, 'dialog');">
        <div class="searchBar">
            <table class="searchContent">
                <tr>
                    <td>
                        <!--角色名：<input type="text" name="role_name"  value="<?php //echo $_input->post('role_name');?>" />-->
                        这里可以批量设置用户权限哦
                    </td>
                    <!--<td><div class="button"><div class="buttonContent"><button type="submit">搜索</button></div></div></td>-->
                </tr>
            </table>
        </div>
    </form>
</div>
<div class="pageContent">
    <table class="table" width="100%" targettype="dialog" layoutH="97">
		<thead>
			<tr>
                <th width="22" align="center"><input type="checkbox" group="role_ids" class="checkboxCtrl"></th>
                <th width="30" align="center">ID</th>
				<th width="50" align="center">角色名称</th>
			</tr>
		</thead>
		<tbody>
            <?php foreach($roles as $v){?>
            <tr target="sid" rel="<?php echo $v['role_id'];?>">
                <td><input name="role_ids" value="<?php echo $v['role_id'];?>" type="checkbox" <?php if(in_array($v['role_id'],$role_ids)) echo 'checked';?>></td>
                <td><?php echo $v['role_id'];?></td>
                <td><?php echo $v['role_name'];?></td>
            </tr>
            <?php }?>
		</tbody>
	</table>
	<div class="formBar">
		<ul>
			<li><a class="button"  href="javascript:void(0);" onclick="setUserRoleCallBack();"><span>确认</span></a></li>
			<li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭</button></div></div></li>
		</ul>
	</div>
</div>
<script type="text/javascript">
function setUserRoleCallBack(){

    var dialog = $("body").data('set_user_role');
    var el = dialog.find("input[name='role_ids']:checked");

    if(el.size()){
        var ids = [];
        el.each(function(){
            ids.push($(this).val());
        });
        $.post('<?php echo SITE_URL . 'index.php?c=user&a=ajaxUserRole';?>',{role_ids:ids,user_id:<?php echo $user_id?>},function(data){
            if(data.statusCode == 200){
                alertMsg.correct(data.message);
                navTab.reloadFlag('user');
            }else{
                alertMsg.error(data.message);
            }
        });

    }else{
        alertMsg.error('至少选择一个角色！');
    }
}
</script>